package com.dsmbase.corp.common;

import net.sf.json.JSONObject;

public class ServiceException extends Exception {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Code code;

	public ServiceException(Code code) {
		super();
		this.code = code;
	}

	public ServiceException(Code code, String message, Throwable cause) {
		super(message, cause);
		this.code = code;
	}

	public ServiceException(Code code, String message) {
		super(message);
		this.code = code;

	}

	public ServiceException(Code code, Throwable cause) {
		super(cause);
		this.code = code;

		// TODO Auto-generated constructor stub
	}

	public JSONObject toJson() {
		JSONObject json = this.code.toJson();
		json.put("msg", this.getMessage());
		return json;
	}

	public Code getCode() {
		return this.code;
	}
}
